﻿//-----------------------------------
//--
//-----------------------------------
function FindProxyForURL(url, host) 
{
	url = url.toLowerCase();
	host = host.toLowerCase();
	var resolved_ip = dnsResolve(host);

// If URL has no dots in host name, send traffic direct.
	if (isPlainHostName(host))
	return "DIRECT";

// 局域网 | for lan
	else if (isInNet(resolved_ip, "10.0.0.0", "255.0.0.0") ||
		isInNet(resolved_ip, "172.16.0.0",  "255.240.0.0") ||
		isInNet(resolved_ip, "192.168.0.0", "255.255.0.0") ||
		isInNet(resolved_ip, "127.0.0.0", "255.255.255.0")
		)
	return "DIRECT";

//协议类型 | protocal type
	else if (shExpMatch(url, "https://*")||
		shExpMatch(url, "ftp://*")
		)
	return "DIRECT";
	
//需要代理 | proxy required
	else if (dnsDomainIs( host, ".hk")||
		dnsDomainIs( host, ".tw")||
		dnsDomainIs( host, ".jp")||
		dnsDomainIs( host, ".us")||
		dnsDomainIs( host, ".en")||
		shExpMatch(url, "*sites.google*")||
		shExpMatch(url, "*.youtube.*")||
		shExpMatch(url, "*.blogspot.*")||
		shExpMatch(url, "*.hk*")||
		shExpMatch(url, "*en-us*")||
		isInNet( host, "67.220.0.0", "255.255.0.0" )
		)
	return "PROXY 127.0.0.1:8000";
	
//其它的 | others
	else return "DIRECT";
}
